﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;

/// <summary>
/// Summary description for SendMail
/// </summary>
public class SendMail
{

    //public static bool SendMail(string toEmail, string subject, string body, bool isHtmlFormat, bool isSSL)
    //{
    //    try
    //    {
    //        SendMail fromEmail = new SendMail();
    //        using (MailMessage message = new MailMessage())
    //        {
    //            // Lấy thông tin email cần gửi
    //            message.From = new MailAddress(fromEmail.GetUserName, "XuXuShop.Info", System.Text.Encoding.UTF8);

    //            message.To.Add(toEmail);

    //            message.Subject = subject;
    //            message.SubjectEncoding = System.Text.Encoding.UTF8;

    //            message.Body = body;
    //            message.BodyEncoding = System.Text.Encoding.UTF8;

    //            message.IsBodyHtml = isHtmlFormat;

    //            message.Priority = MailPriority.High;


    //            // Chứng thực và thiết lập an toàn e-mail gửi
    //            SmtpClient client = new SmtpClient();


    //            // Email & Password
    //            NetworkCredential netCre = new NetworkCredential(fromEmail.GetUserName, fromEmail.GetPassword);

    //            // Credentials
    //            client.UseDefaultCredentials = true;
    //            client.Credentials = netCre;

    //            // Mã hóa đường truyền (Secure Sockets Layer)
    //            client.EnableSsl = isSSL;
    //            // 587
    //            client.Port = fromEmail.GetPort;
    //            // smtp.gmail.com
    //            client.Host = fromEmail.GetHost;

    //            // Bắt đầu gửi mail
    //            client.Send(message);
    //        }
    //    }
    //    catch (Exception)
    //    {
    //        return false;
    //    }
    //    return true;
    //}
}